package com.ruoyi.project.hcy.notice.service;

import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.project.hcy.notice.domain.NoticeAndType;
import com.ruoyi.project.hcy.notice.domain.Notices;
import com.ruoyi.project.hcy.notice.mapper.NoticeAndTypeMapper;
import com.ruoyi.project.hcy.notice.mapper.NoticeManagerMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NoticeMangerImpl implements INoticeManagerService {

    @Autowired
    private NoticeManagerMapper noticeManagerMapper;

    @Autowired
    private NoticeAndTypeMapper noticeAndTypeMapper;

    @Override
    public List<Notices> selectNoticesList(Notices notices) {

        return noticeManagerMapper.selectNoticesList(notices);
    }

    /**
     * 增加
     * @param notices
     * @return
     */
    @Override
    public int insertNotices(Notices notices) {

        return noticeManagerMapper.insertNotices(notices);
    }

    @Override
    public int deleteNoticesByIds(String ids) {
        Integer[] noticesIds = Convert.toIntArray(ids);
        System.out.println(noticesIds);
        return noticeManagerMapper.deleteNoticesByIds(noticesIds);
    }

    @Override
    public Notices selectNoticesById(Integer noticeId) {

        return noticeManagerMapper.selectNoticesById(noticeId);
    }

    @Override
    public int updateNotices(Notices notices) {
        return noticeManagerMapper.updateNotices(notices);
    }


    //更新连接表hcy_notice_type_notice
    @Override
    public int updateNoticeAndType(Integer typeId, Integer noticeId) {
        NoticeAndType noticeAndType = new NoticeAndType(typeId, noticeId);
        return noticeAndTypeMapper.updateNoticeAndType(noticeAndType);
    }
}
